import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

// 6531031914842725
public class P68 {
	private static Set<String> set = new TreeSet<String>();
	private static int x = 5;
	
	public static void getPermutationList(String num, String result) {
		if (num.length() == 0) {
			
			//System.out.println(result);
			int[][] m = new int[x][3];
			search(m, result);
			
			
			Set<Integer> sumSet = new HashSet<Integer>();
			for (int i = 0; i < m.length; i++) {
				int sum = 0;
				for (int j = 0; j < m[i].length; j++) {
					sum += m[i][j];
				}
				
				sumSet.add(sum);
				
				if (sumSet.size() >= 2) {
					break;
				}
			}
			
			if (sumSet.size() == 1) {
				String x = concat(m);
				System.out.println(">>>" + x);
				//System.out.println(">>>" + x.length());				
				if (x.length() == 16) {
					System.out.println(x);
					set.add(x);
				}
			}
			
			return;
		}

		for (int i = 0; i < num.length(); i++) {
			String n = num.substring(i, i + 1);
			getPermutationList(num.substring(0, i) + num.substring(i + 1), result + n);
		}
	}
	
	public static void main(String[] args) {
				
	
		StringBuffer buffer = new StringBuffer();
		for (int i = 1; i <= x * 2; i++) {
			if (i == 10) {
				buffer.append("A");
			} else {
				buffer.append(i);
			}
		}
		
		System.out.println(buffer.toString());
		getPermutationList(buffer.toString(), "");
		
		
		String[] lines = set.toArray(new String[0]);
		for (String line : lines) {
			System.out.println(line);
		}
	}
	
	public static String concat(int[][] m) {
		int min = Integer.MAX_VALUE;
		int index = 0;
		
		for (int i= 0; i < m.length; i++) {
			if (min > m[i][0]) {
				min = m[i][0];
				index = i;
			}
		}
		
		
		StringBuffer buffer = new StringBuffer();
		
		for (int i = index; i < index + m.length; i++) {
			int x = i%m.length;
			for (int j= 0; j < m[x].length; j++) {
				buffer.append(m[x][j]);
			}
		}
		return buffer.toString();
	}
	
	public static void search(int[][] m, String nums) {
		
		for (int i = 0; i < m.length; i++) {
			for (int j = 0; j < m[i].length; j++) {
				//System.out.println(">>>" + i  + "," + j + " " + nums);
				if (m[i][j] == 0) {					
					String c = nums.substring(0, 1);
					if (c.equals("A")) {
						//System.out.println("OK");
						m[i][j] = 10;
					} else {
						m[i][j] = Integer.parseInt(c);
					}
					//System.out.println(i + "," + j + ":" + m[i][j]);
					nums = nums.substring(1);
					
					if (j == 1) {
						if (m[m.length - 1][2] == 0) {
							m[m.length - 1][2] = m[i][j];
						}
					} else if (j == 2) {
						if (m[(i + 1)%x][1] == 0) {
							m[(i + 1)%x][1] = m[i][j];
						}
					}
				}
			}		
		}
	}
}
